//
//  SceneryDetailParse.m
//  LocalTravel
//
//  Created by zheng ji on 14-3-16.
//  Copyright (c) 2014年 jxw. All rights reserved.
//

#import "SceneryDetailParse.h"
@interface SceneryDetailParse ()
{
   NSMutableDictionary* _sceneryDict;

   NSString* _currentElementName;
}
@end


@implementation SceneryDetailParse
-(SceneryDetailParse*)initWithXmlData:(NSString*)xmlData{
    
    NSXMLParser* parser=[[NSXMLParser alloc] initWithData:[xmlData dataUsingEncoding:NSUTF8StringEncoding]];
    parser.delegate=self;
    parser.shouldProcessNamespaces=NO;
    [parser parse];
    
    return  self;
}
-(void)parserDidStartDocument:(NSXMLParser *)parser{
    _sceneryDict=[[NSMutableDictionary alloc]init];
}
-(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict{
    _currentElementName=elementName;
    
    
    
}
-(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName{
    
}
-(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)value{
    if([_currentElementName isEqualToString:@"intro"]){
        [_sceneryDict setObject:value forKey:_currentElementName];
    }
    if([_currentElementName isEqualToString:@"buyNotice"]){
        [_sceneryDict setObject:value forKey:_currentElementName];
    }
    if([_currentElementName isEqualToString:@"address"]){
        [_sceneryDict setObject:value forKey:_currentElementName];
    }
    
}
-(void)parserDidEndDocument:(NSXMLParser *)parser{
    
}
-(void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError{
    
}

-(NSDictionary*) getScenaryDetail{
    return _sceneryDict;
}
@end
